package com.wn.class30.service.impl;

import com.wn.class30.entity.Business;
import com.wn.class30.entity.BusinessExample;
import com.wn.class30.mapper.BusinessDao;
import com.wn.class30.service.WXBussinessService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class WXbusinessServiceImpl implements WXBussinessService {
@Resource
    private BusinessDao businessDao;
    @Override
    public List<Business> queryBusinesses(Double latitude, Double longitude) throws Exception {
        BusinessExample businessExample = new BusinessExample();
        businessExample.setLat(latitude);
        businessExample.setLon(longitude);
        List<Business> businesses = businessDao.selectByLocation(businessExample);
        List<Business> objects = new ArrayList();
        if(businesses!=null && businesses.size()!=0){
            for (Business bus:businesses){
                       if(bus.getDistance()<=10000){
                           objects.add(bus);
                       }
            }
        }
        return objects;
    }
}
